home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1997 January / cd joy 78 No20.iso / mac / Les démos / Amber.sea / AMBER-JB™ interactive demo / AMBERHUB.dxr / 00033_Field_RearWindow.KILL when done.txt < prev    next >
Text File  |  1996-10-28  |  9KB  |  342 lines

  1. -- RearWindow XObject Example Movie
  2. -- by David Jackson-Shields
  3. -- vers. 1.0.2 (10/11/93)
  4. --
  5. -- ¬© 1992-94 by Macromedia, Inc. and David Jackson-Shields
  6. -- All Rights Reserved
  7. --
  8. -- This movie demonstrates the use of the RearWindow XObject, which requires
  9. -- System 6.0.5 or later.
  10. -- The uses of the "RearWindow XObject" are:
  11. -- (1) When using a Stage size smaller than your monitor screen...you
  12. --     can cover the Finder Desktop when running on system 7.x or later,
  13. --     (or when running with systems 6.0.7 or later under "Multi-Finder" mode.)
  14. --     Options include filling the Rear Window with:
  15. --       (A) a 1-bit QuickDraw pattern: white, ltGray, gray, dkGray, black
  16. --       (B) the Finder Desktop pattern (whether color or black & white)
  17. --       (C) an indexed color of the current palette
  18. --       (D) an RGB color (specified by Red, Green, Blue values)
  19. --       (E) a Director bitmapped castMember (either stretched or non-stretched)
  20. --       (F) a PICT file image (either stretched or non-stretched)
  21. -- (2) To obtain the monitor screen pixel dimensions (top, left, bottom, right)
  22.  
  23. -- NOTE: The addition of an extra window even larger than your Stage will
  24. -- impact the memory requirements of your project. Check the "About MM"
  25. -- memory guage, or put the freeBytes and the freeBlock in the message
  26. -- window to see the impact this extra window has, and adjust your movie‚Äôs 
  27. -- memory management as needed. In addition, a copy of any castMember or
  28. -- PICT file image used in RearWindow is kept in RAM. This is so it can 
  29. -- be redrawn in the RearWindow during update events...(like when the user
  30. -- opens a Desk Accessory or goes to MultiFinder and back, etc.)
  31.  
  32.  
  33. on ZZZstartMovie
  34.   
  35.   initRearWindow
  36.   --coverDesktop -99
  37.   
  38. end ZZZstartMovie
  39.  
  40. --
  41.  
  42. on ZZZstopMovie
  43.   
  44.   releaseRearWindow
  45.   
  46. end ZZZstopMovie
  47.  
  48. --
  49.  
  50. on ZZZinitRearWindow
  51.   
  52.   global rwObj, gMaxColors, deskTopPattern, black
  53.   
  54.   set x = the colorDepth
  55.   
  56.   -- assign maximum index colors for the color depth setting:
  57.   if x >= 8 then set gMaxColors = 255
  58.   if x = 4 then set gMaxColors =  15
  59.   if x = 2 then set gMaxColors =   3
  60.   if x = 1 then set gMaxColors =   0
  61.   if gMaxColors = 255 then
  62.     put string( 100 ) into field "colorIndex" -- 100 works well with the stagecolor
  63.   else
  64.     put string( gMaxColors/2 ) into field "colorIndex"
  65.   end if
  66.   
  67.   -- You must open an external library file if you do not have
  68.   -- the "RearWindow" XCOD resource in the movie using ResEdit:
  69.   if factory( "RearWindow" ) = 0 then
  70.     OpenXLib "RearWindow.XObj"
  71.   end if
  72.   
  73.   initGlobals
  74.   if objectP( rwObj ) then rwObj( mDispose )
  75.   makeObjIfNeeded
  76.   when mouseDown then mouseHandler
  77.   when keyDown then keyHandler
  78.   
  79. end initRearWindow
  80.  
  81. --
  82.  
  83. on ZZZreleaseRearWindow
  84.   
  85.   global rwObj
  86.   if objectP( rwObj ) then
  87.     rwObj( mDispose )
  88.   end if
  89.   
  90.   -- You must Close the Xlib if you do not have
  91.   -- the XCOD resource installed in the movie with ResEdit:
  92.   CloseXLib
  93.   
  94.   put " " into field "stage&Screen"
  95.   put " " into field "colorIndex"
  96.   set the mouseDownScript to EMPTY
  97.   set the keyDownScript   to EMPTY
  98.   
  99. end releaseRearWindow
  100.  
  101. --
  102.  
  103. on ZZZinitGlobals
  104.   
  105.   -- these 1-bit pattern values are constantized in this example movie
  106.   -- for use when  calling the coverDesktop handler from button scripts:
  107.   global white, ltGray, gray, dkGray, black, deskTopPattern
  108.   
  109.   set white   =  -1
  110.   set ltGray  =  -2
  111.   set Gray    =  -3
  112.   set dkGray  =  -4
  113.   set black   =  -5
  114.   
  115.   -- The Finder Desktop pattern is the default case. To specify the
  116.   -- Finder Desktop, use any negative integer less than -5:
  117.   
  118.   set deskTopPattern = -99
  119.   
  120. end initGlobals
  121.  
  122. -- shows the name "Macromedia Director 3.x", "MacroMind Player 3.x", or
  123. -- the name of the Projector:
  124.  
  125. on ZZZdisplayAppName
  126.   
  127.   global rwObj
  128.   put rwObj( mGetAppName ) into returnStr
  129.   put "The name of the current application is:" & RETURN & ¬¨
  130.        QUOTE & returnStr & QUOTE into field "stage&screen"
  131.   
  132. end displayAppName
  133.  
  134. -- fills the RearWindow with 1-bit patterns or the DeskTop pattern:
  135.  
  136. on ZZZcoverDesktop patVar
  137.   
  138.   global rwObj
  139.   makeObjIfNeeded 
  140.   rwObj( mPatToWindow, patVar )
  141.   
  142. end coverDesktop
  143.  
  144. --
  145.  
  146. on ZZZloadPICT
  147.   
  148.   global rwObj
  149.   makeObjIfNeeded
  150.   set fileName = the pathName & "Background.PICT"
  151.   set retValue = rwObj( mPICTtoWindow, fileName, 1, -99 )
  152.   if value( retValue ) < 0 then
  153.     alert "System error" && retValue && "trying to load PICT file" && QUOTE & ¬¨
  154.           fileName & QUOTE
  155.     stopMovie
  156.     exit
  157.   end if
  158.   
  159. end loadPICT
  160.  
  161. --
  162.  
  163. on ZZZloadCast castName
  164.   
  165.   global rwObj
  166.   makeObjIfNeeded
  167.   set myPic = the picture of cast castName
  168.   set retValue = rwObj( mCastToWindow, myPic, 1, -99 )
  169.   if value( retValue ) < 0 then
  170.     alert "Error trying to load castMember" && QUOTE & castName & QUOTE
  171.     stopMovie
  172.     exit
  173.   end if
  174.   
  175. end loadCast
  176.  
  177. --
  178.  
  179. on ZZZUnCoverDesktop
  180.   
  181.   
  182. end UnCoverDesktop
  183.  
  184. --
  185.  
  186. on ZZZmakeObjIfNeeded
  187.   
  188.   global rwObj
  189.   if not objectP( rwObj ) then
  190.     
  191.     -- "M" indicates multiple monitors, "S" is for single monitor configuration.
  192.     -- ONLY use "S" if there is not enough room for multiple monitors.
  193.     -- So first...let‚Äôs try it with multiple-monitor configuration:
  194.     set rwObj = RearWindow( mNew, "M" )    
  195.     if value( rwObj ) < 0 then
  196.       alert "System error" && rwObj && ¬¨
  197.             "trying to create the RearWindow object in RAM (multiple-monitor config)."
  198.       stopMovie
  199.       exit
  200.     end if
  201.     writeStageAndScreenBounds
  202.     if the freeBlock < rwObj( mGetMemoryNeeded ) then
  203.       -- delete the object and create it again with a single-monitor config...
  204.       if objectP( rwObj ) then
  205.         rwObj( mDispose )
  206.         set rwObj = RearWindow( mNew, "S" )
  207.       end if
  208.       
  209.       if value( rwObj ) < 0 then
  210.         alert "System error" && rwObj && ¬¨
  211.             "trying to create the RearWindow object in RAM (single-monitor config)."
  212.         stopMovie
  213.         exit
  214.       end if
  215.       writeStageAndScreenBounds
  216.     end if
  217.   end if
  218.   
  219. end makeObjIfNeeded
  220.  
  221. --
  222.  
  223. on writeStageAndScreenBounds
  224.   
  225.   global rwObj
  226.   set s = "Minimum Rect around All Screens:"
  227.   set s = s && rwObj( mGetScreenTop    ) & ", "
  228.   set s = s && rwObj( mGetScreenLeft   ) & ", "
  229.   set s = s && rwObj( mGetScreenBottom ) & ", "
  230.   set s = s && rwObj( mGetScreenRight  ) & RETURN
  231.   set s = s &  "Stage dimensions are:"
  232.   set s = s && the stageTop & ", "
  233.   set s = s && the stageLeft & ", "
  234.   set s = s && the stageBottom & ", "
  235.   set s = s && the stageRight
  236.   put s into field "stage&Screen"
  237.   
  238. end writeStageAndScreenBounds
  239.  
  240. -- this method works best with the Monitors Control Panel set to
  241. -- 256 colors. It also works with fewer colors. With the Control
  242. -- Panel set to ‚Äúthousands‚Äù or ‚Äúmillions‚Äù of colors...the choice
  243. -- of color is unpredictable.
  244.  
  245. on fillWithIndexColor
  246.   
  247.   global rwObj
  248.   makeObjIfNeeded
  249.   -- assigning index color:
  250.   set patVar = value( field "colorIndex" )
  251.   rwObj( mIndexColorToWindow, patVar )
  252.   
  253. end fillWithIndexColor
  254.  
  255. -- this method only works with the Monitors Control Panel set to
  256. -- ‚Äúthousands‚Äù or ‚Äúmillions‚Äù of colors:
  257.  
  258. on fillWithRGBColor
  259.   
  260.   global rwObj
  261.   makeObjIfNeeded
  262.   -- assigning Red, Green, and Blue values of the color:
  263.   rwObj( mRGBColorToWindow, 10000, 25000, 65000 )
  264.   
  265. end fillWithRGBColor
  266.  
  267. --
  268.  
  269. on mouseHandler
  270.   
  271.   if ( the clickOn = 19 ) OR ( the clickOn = 20 ) then 
  272.     if the clickOn = 19 then
  273.       bumpCIndex +1
  274.     else if the clickOn = 20 then
  275.       bumpCIndex -1
  276.     end if
  277.   end if
  278.   
  279. end mouseHandler
  280.  
  281. --
  282.  
  283. on keyHandler
  284.   
  285.   if the key = RETURN then
  286.     fillWithIndexColor
  287.     dontPassEvent
  288.   end if
  289.   
  290. end keyHandler
  291.  
  292. -- a parameter of +1 increments the index, whereas 
  293. -- a parameter of -1 decrements it:
  294.  
  295. on bumpCIndex direction
  296.   
  297.   global rwObj, white, gMaxColors
  298.   set cIndex = value( field "colorIndex" )
  299.   if integerP( cIndex ) then
  300.     set cIndex = cIndex + direction
  301.     if ( cIndex < 0 ) OR ( cIndex > gMaxColors ) then
  302.       exit
  303.     else
  304.       put string( cIndex ) into field "colorIndex"
  305.       if cIndex then
  306.         makeObjIfNeeded
  307.         rwObj( mIndexColorToWindow, cIndex )
  308.       else
  309.         coverDesktop white
  310.       end if
  311.       repeat while the stillDown
  312.         set cIndex = cIndex + direction
  313.         if ( cIndex < 0 ) OR ( cIndex > gMaxColors ) then
  314.           exit
  315.         else
  316.           put string( cIndex ) into field "colorIndex"
  317.           if cIndex then
  318.             makeObjIfNeeded
  319.             rwObj( mIndexColorToWindow, cIndex )
  320.           else
  321.             coverDesktop white
  322.           end if
  323.         end if
  324.       end repeat
  325.     end if
  326.   end if
  327.   
  328. end decrCIndex
  329.  
  330. --
  331.  
  332. on wait n
  333.   
  334.   startTimer
  335.   repeat while the timer < n
  336.   end repeat  
  337.   
  338. end wait
  339.  
  340. -- 
  341.  
  342.